<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script>
        var davidniu ={
            name:"牛 力",
            birth: 1965,
            //方法
            //age:function (){
              //  var now = new Date().getFullYear();
                //return now - this.birth;
            //}
            age:getAge
        }
        function getAge(){
            var now = new Date().getFullYear();
            return now - this.birth;
        }
        //davidniu.age()//ok
        //getAge() //NaN 因为window在调用
        getAge.apply(davidniu,[]);//this指向了davidniu,参数为空
    </script>
</head>
<body>

</body>
</html>